import { getPrimaryAddress } from '@/api/address'
import { ref } from 'vue'
import { AddressOptions } from './types'

const useAddressOptions = () => {
  const addressOptions = ref<Array<AddressOptions>>([])
  const getAddressOptionsLoading = ref(false)
  const getAddressOptions = async () => {
    getAddressOptionsLoading.value = true
    const res = await getPrimaryAddress()
    addressOptions.value = res.data.data.rows
    getAddressOptionsLoading.value = false
  }

  return {
    addressOptions,
    getAddressOptionsLoading,
    getAddressOptions,
  }
}

export default useAddressOptions
